package work.huangxin.share.util;

import cn.hutool.core.date.DateTime;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * @author 季台星
 * @Date 2023 04 28 20 48
 * 得到当前天距离周一的天数
 */
public class ParseWeekDay {
    public static int getDays(){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        //获得日期类
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        String monday = simpleDateFormat.format(calendar.getTime());
        String[] split = monday.split("-");
        Integer mondayTime = Integer.valueOf(split[2]);
        String current = simpleDateFormat.format(Date.from(Instant.now()));
        String[] split1 = current.split("-");
        return Integer.valueOf(split1[2]) - mondayTime;

    }
}
